﻿----------------------------------------------------------------------------------------------------
--
--  © 2012 Stanislav S. Yarmonov.
--
--  TODO:LICENSE
--     
----------------------------------------------------------------------------------------------------
IF OBJECT_ID(N'[_DB].[Schema_Exists]', 'FN') IS NOT NULL
	DROP FUNCTION [_DB].[Schema_Exists]
GO

----------------------------------------------------------------------------------------------------
--
--  Check the existance of the schema.
--
--  INPUT
--		@@Name
--		Name of the schema to be checked.
--
----------------------------------------------------------------------------------------------------
CREATE FUNCTION [_DB].[Schema_Exists] (
	@@Name [sysname]
)
RETURNS [bit]
AS
BEGIN
	RETURN CASE
		WHEN SCHEMA_ID(QUOTENAME(@@Name)) IS NULL THEN 0
		ELSE 1
	END
END
GO
